package chenxi.proxy;

import lombok.AllArgsConstructor;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @author bowen
 */
@AllArgsConstructor
public class JdkProxyHandler implements InvocationHandler {

    private Object targetObject;

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        proxyMethod();
        return method.invoke(targetObject, args);
    }

    private void proxyMethod() {
        System.out.println("代理方法被调用");
    }
}
